package com.neu.wangweili.servlet;

import com.neu.wangweili.service.W_StuService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "DeleteBatchStuServlet", urlPatterns = {"/DeleteBatchStuServlet"})
public class DeleteBatchStuServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {


        String[] stu_id=request.getParameterValues("stuBox");
        W_StuService WStuService =new W_StuService();
        int sum= WStuService.deleteBatch(stu_id);

        if(sum==stu_id.length){
            request.getRequestDispatcher("commons/success.jsp").forward(request,response);
        }else{
            System.out.println("您有"+(stu_id.length-sum)+"条信息删除失败");
            request.getRequestDispatcher("commons/fail.jsp").forward(request,response);
        }

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
